import http from "../fui-request";

/**
 * 登录
 * @param {string} username
 * @param {string} password
 */
export function fetchLogin(data) {
	return http.request({
		url: '/home/api/v1/index/user/login',
		method: 'POST',
		data,
		skipErrorHandler: true
	});
}


/**
 * 获取城市
 */
export function fetchCities(data) {
	return http.request({
		url: '/home/api/v1/index/cities',
		method: 'get',
		data,
	});
}

/**
 * 获取部门
 * @param	id	城市id
 */
export function fetchDepartments(id) {
	return http.request({
		url: `/home/api/v1/index/departments/${id}`,
		method: 'get',
	});
}

/**
 * 获取 获客渠道
 * @param	type	渠道type
 */
export function fetchChannel(type) {
	return http.request({
		url: `/home/api/v1/index/customer_acquisition_channels/${type}`,
		method: 'get',
	});
}

/**
 * 获取 产品类型
 */
export function fetchProductType() {
	return http.request({
		url: `/home/api/v1/index/product_type`,
		method: 'get',
	});
}

/**
 * 获取 产品类型细分
 */
export function fetchProductSubType(type_id) {
	return http.request({
		url: `/home/api/v1/index/product_subtype/${type_id}`,
		method: 'get',
	});
}

/**
 * 获取 辅助人员列表
 * @param	name	名称
 */
export function fetchSupportStaff(data) {
	return http.request({
		url: `/home/api/v1/index/support_person/list`,
		method: 'get',
		data
	});
}

/**
 * 获取 提交报单
 */
export function submitReportingForm(data) {
	return http.request({
		url: `/home/api/v1/index/form/submit`,
		method: 'post',
		data
	});
}

/**
 * 提交记录列表
 */
export function fetchRecordsPage(data) {
	return http.request({
		url: '/home/api/v1/index/form/list',
		method: 'get',
		data
	});
}

/**
 * 复制
 */
export function fetchCopyInfo(id) {
	return http.request({
		url: `/home/api/v1/index/form/copy/${id}`,
		method: 'get',
	});
}

/**
 * 编辑详情
 */
export function fetchDetail(id) {
	return http.request({
		url: `/home/api/v1/index/form/detail/${id}`,
		method: 'get',
	});
}

/**
 * 编辑提交
 */
export function submitEditForm(id, data) {
	return http.request({
		url: `/home/api/v1/index/form/edit/${id}`,
		method: 'post',
		data
	});
}

/**
 * 详情
 */
export function fetchDetailInfo(id) {
	return http.request({
		url: `/home/api/v1/index/form/info/${id}`,
		method: 'get',
	});
}

/**
 * 注册
 */
export function submitRegister(data) {
	return http.request({
		url: `/home/api/v1/index/user/register`,
		method: 'post',
		data
	});
}

/**
 * 忘记密码
 */
export function submitForgetPassword(data) {
	return http.request({
		url: `/home/api/v1/index/user/forgot_password`,
		method: 'post',
		data
	});
}

/**
 * 个人信息
 */
export function fetchUserinfo(data) {
	return http.request({
		url: `/home/api/v1/index/user/detail`,
		method: 'get',
		data
	});
}

/**
 * 首页
 */
export function fetchIndexData(data) {
	return http.request({
		url: `/home/api/v1/index`,
		method: 'get',
		data
	});
}

/**
 * 获取 支付途径列表
 */
export function fetchPayMethodList(data) {
	return http.request({
		url: `/home/api/v1/index/payment_methods`,
		method: 'get',
		data
	});
}


